<div class="box-tools" style="top:10px; display: inline-block">
  <form class="form-inline" id="project—form" action="{:url('Hetong/hetongcf')}" method="GET" pjax-search="">
    <div class="form-group">
      <label for="hetongname">合同名称</label>
      <input type="text" style="width: 166px" id="hetongname" name="hetongname" class="form-control"
             value="{:input('get.hetongname')}"/>
    </div>
    <div class="form-group">
      <label for="username">用户姓名</label>
      <input type="text" style="width: 166px" id="username" name="username" class="form-control"
             value="{:input('get.username')}"/>
    </div>
    <div class="form-group">
      <label for="idcard">身份证号</label>
      <input type="text" style="width: 166px" id="idcard" name="certificate" class="form-control"
             value="{:input('get.certificate')}"/>
    </div>
    <div class="form-group">
      <label for="sign">状态</label>
      <select class="form-control" id="sign" name="sign" style="border-radius:2px;">
        <option value="-1">全部</option>
        <option value="3" {if condition="input('get.sign') eq 3" }selected="selected" {/if} >签署成功</option>
        <option value="1" {if condition="input('get.sign') eq 1" }selected="selected" {/if} >公司未签章</option>
        <option value="0" {if condition="input('get.sign') eq 0" }selected="selected" {/if} >用户未签署</option>
      </select>
    </div>
    <div class="form-group">
      <label for="start_date">开始时间</label>
      <input class="form-control timepicker" id="start_date" name="start_date" autocomplete="off" style="width: 100px"
             value="{:input('get.start_date')}">
      <!--<div class="input-group-addon"><i class="fa fa-clock-o"></i></div>-->
    </div>
    <div class="form-group">
      <label for="end_date">结束时间</label>
      <input class="form-control timepicker" id="end_date" name="end_date" autocomplete="off" style="width: 100px"
             value="{:input('get.end_date')}">
      <!--<div class="input-group-addon"><i class="fa fa-clock-o"></i></div>-->
    </div>
    <div class="form-group">
      <button type="submit" class="btn btn-primary sreachs" onClick="return toVailds()">搜索</button>
      <button type="button" class="btn btn-primary" onclick="resetForm()">重置</button>
    </div>
  </form>
</div>
<style>
  .form-group {
    margin-bottom: 0;
  }
</style>
<script>
    $(function () {
        let start_date = $('#start_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn'),
        }).on('dp.change', function (e) {
           let initEndDate = $('#end_date').val()
            end_date.data('DateTimePicker').minDate(e.date);
            if(initEndDate === ''){
              $('#end_date').val('')
            }

        });
        let end_date = $('#end_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        }).on('dp.change', function (e) {
            start_date.data('DateTimePicker').maxDate(e.date);
        });
    })

    function toVailds() {
        let id = $('#idcard').val()
        var idreg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        let validate = false
        if (id === '') {
            validate = true
        } else if (!idreg.test(id)) {
            $.amaran({'message': '请输入正确的身份证号码!'});
            validate = false
        } else {
            validate = true
        }
        return validate
    }

    function resetForm() {
        $('input[name="hetongname"]').val('')
        $('input[name="username"]').val('')
        $('input[name="certificate"]').val('')
        $('select[name="sign"]').val('-1')
        $('input[name="start_date"]').val('')
        $('input[name="end_date"]').val('')
        $('#project—form').submit()
    }
</script>